package com.zhao.blackBox.originator;

import com.zhao.blackBox.memento.Memento;

public class GameRole {

    private Integer rtk;

    private Integer def;

    public void initProp() {
        this.rtk = 100;
        this.def = 100;
    }

    public void fight() {
        this.rtk = 0;
        this.def = 0;
    }

    public Memento setMemento() {
        return new GameRoleMemento(this.rtk, this.def);
    }

    public void recoverMemento(Memento memento) {
        GameRoleMemento roleMemento = (GameRoleMemento) memento;
        this.rtk = roleMemento.getRtk();
        this.def = roleMemento.getDef();
    }

    public void printStat() {
        System.out.println("伤害：" + this.rtk);
        System.out.println("防御：" + this.def);
    }

    private class GameRoleMemento implements Memento {

        private Integer rtk;

        private Integer def;

        public GameRoleMemento(Integer rtk, Integer def) {
            this.rtk = rtk;
            this.def = def;
        }

        public Integer getRtk() {
            return rtk;
        }

        public Integer getDef() {
            return def;
        }
    }
}
